package com.edg.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestMapping;

public class LoginControler {

    @RequestMapping("/login")
    public String login(String username,String pwd){
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(username,pwd);
        try {
            subject.login(token);
        }catch (UnknownAccountException e){
            e.printStackTrace();//用户名错误
        }catch (IncorrectCredentialsException e){
            e.printStackTrace();//密码错误
        }

        return null;
    }
}
